using System.Collections.Generic;
using Android.App;
using Android.Views;
using Android.Widget;

namespace testApp.XcoAppSpaces.Core
{
	class EventListAdapter : BaseAdapter<string>
	{
		private List<string> items = new List<string>();
		private Activity context;

		public EventListAdapter(Activity context) : base() {
			this.context = context;
		}

		public void Add(string item)
		{
			items.Add(item);
		}

		#region implemented abstract members of BaseAdapter

		public override long GetItemId(int position)
		{
			return position;
		}
		public override string this[int position] {  
			get { return items[position]; }
		}
		public override int Count {
			get { return items.Count; }
		}
		public override View GetView(int position, View convertView, ViewGroup parent)
		{
			View view = convertView; // re-use an existing view, if one is available
			if (view == null) // otherwise create a new one
				view = context.LayoutInflater.Inflate(Android.Resource.Layout.SimpleListItem1, null);
			view.FindViewById<TextView>(Android.Resource.Id.Text1).Text = items[position];
			return view;
		}


		#endregion


	}
}